<?Lassoscript
// Last modified 11/29/09 by Eric Landmann

// FUNCTIONALITY
// Post search form

// CHANGE NOTES
// 11/29/09
// Got it working

// Debugging
// Var:'svDebug' = 'Y';

Var:'vError'=(Action_Param:'Error');
Var:'vID'=(Action_Param:'ID');
Var:'vSID'=(Action_Param:'SID');
Var:'vTopic'=(Action_Param:'Topic');
Var:'vPoster'=(Action_Param:'Poster');
Var:'vMessage'=(Action_Param:'Message');
Var:'ResponsePage' = string;

// Admin Search
If: (Response_Filepath) >> 'setup_edit.lasso';
	$ResponsePage = 'setup_searchresults.lasso';
// Non-Admin Search
Else: (Response_Filepath) >> 'search.lasso';
	$ResponsePage = 'searchresponse.lasso';
/If;

?><form action="[$ResponsePage]" method="post">
	<div align="center">
		<table width="491">
			<tr>
				<td colspan="2">
					<h2>Search for Messages</h2> 
<?Lassoscript
// Standard Error Table
If: (Var:'vError') != '';
	LI_ShowError3: -ErrNum=$vError, -Option=$vOption;
/If;
?>
				</td>
			</tr>
			<tr>
				<td width="150" bgcolor="[Var:'svSearchContentColor']" valign="middle">
					<div align="right">
						<strong>ID</strong>
						<br>
						Exact match only
					</div>
				</td>
				<td align="top" bgcolor="[Var:'svPostContentColor']">
					<input type="text" name="ID" value="[Var:'vID']" size="12">
				</td>
			</tr>
			<tr>
				<td width="150" bgcolor="[Var:'svSearchContentColor']" valign="middle">
					<div align="right">
						<strong>Topic</strong>
						<br>
						Partial topic OK
					</div>
				</td>
				<td align="top" bgcolor="[Var:'svPostContentColor']">
					<input type="text" name="Topic" value="[Var:'vTopic']" size="30"> 
				</td>
			</tr>
			<tr>
				<td width="150" bgcolor="[Var:'svSearchContentColor']" valign="middle">
					<div align="right"><strong>Section</strong></div>
				</td>
<?Lassoscript
// Get list of Sections
Var:'vSQLSearchSections'='SELECT * FROM ' $svSectionsTable ' WHERE Allow = "Y" ORDER BY Section_Title';
Inline: $IV_SearchSections, -SQL=$vSQLSearchSections;
	'\t<td bgcolor="'($svPostContentColor)'"><select name="SID">\n';
	'\t\t<option value=""'; If: (Var:'vSID') == ''; ' selected'; /If; '>--- Show All---</option>\n';
	Records;
		'\t\t\t<option value="'(Field:'Section_ID') '"'; If: (Field:'Section_ID') == ($vSID); ' selected'; /If; '>'(Field:'Section_Title')'</option>\n';
	/Records;
	'\t\t</select><br></div>\n';
/Inline;

?> 				</td>
			</tr>
			<tr>
				<td width="150" bgcolor="[Var:'svSearchContentColor']" valign="middle">
					<div align="right">
						<strong>Poster</strong>
						<br>
						Partial name OK
					</div>
				</td>
				<td align="top" bgcolor="[Var:'svPostContentColor']">
					<input type="text" name="Poster" value="[Var:'vPoster']" size="20"> 
				</td>
			</tr>
			<tr>
				<td width="150" bgcolor="[Var:'svSearchContentColor']" valign="middle">
					<div align="right">
						<strong>Message</strong>
						<br>
						Partial phrase OK
					</div>
				</td>
				<td align="top" bgcolor="[Var:'svPostContentColor']">
					<input type="text" name="Message" value="[Var:'vMessage']" size="30"> 
				</td>
			</tr>
			<tr>
				<td colspan="2" bgcolor="[Var:'svSearchContentColor']">
					<div align="center">
						<input type="hidden" name="New" value="Y">
						<input type="hidden" name="Datatype" value="Post">
						<input type="submit" name="-Nothing" value="Search">
					</div>
				</td>
			</tr>
		</table>
	</div>
</form>
